<?php
session_start ();
header ( 'Content-Type: text/html; charset=UTF-8' );
require_once ("../in/tren.php");
$tit = 'Game Yêu Thích';
echo '<div class="navigation"><b>Game Yêu Thích</b></div><div align="right"><div style="border-top: 3px solid #13cfeb;"></div></div></div>';
$c = "SELECT count(*) FROM giohang where ten='" . $taikhoan ['nick'] . "'";
$c = mysql_query ( $c );
$total = mysql_result ( $c, 0 );
$p = $_GET ['p'];
if (empty ( $_GET ['p'] ))
	$p = 1;
if ($p > 1)
	$hal = ' Page #' . $p;
$show = 10;
if ($total == 0) {
	echo '<div class="main_menu">(Trống)</div>';
} else {
	$pg = ceil ( $total / $show );
	if ($p > $pg && $p != 1)
		$p = $pg;
	if ($p < 1)
		$p = 1;
	$j = ($p - 1) * $show;
	$a = mysql_query ( "select * from giohang where ten = '" . $taikhoan ['nick'] . "' order by id desc limit $j, $show;" );
	while ( $d = mysql_fetch_array ( $a ) ) {
		$ar = mysql_fetch_array ( mysql_query ( "SELECT * FROM game WHERE id='" . $d ['idgame'] . "'" ) );
		$file = $ar ['link'];
		$size = filesize ( '../fgame/' . $file . '' ) / 1000;
		echo '<table cellspacing="0" class="block"><tbody><tr><td class="img"><img src="../fgame/' . $ar ['icon'] . '" alt="" height="30" width="30"></td><td><span style="color: #ff0099;">&bull;</span><a href="index.php?id=' . $ar ['id'] . '">' . $ar ['tieude'] . '</a><br/><span style="color: #ff0099;">&bull;</span>Cỡ: ' . $size . 'kb<br/><span style="color: #ff0099;">&bull;</span>' . $ar ['down'] . ' lượt tải.</td></tr></tbody></table><div style="border-top: 1px dotted gray; margin: 1px"></div>';
	}
	if ($total > $show) {
		echo '<div class="page">';
		$sc = 10;
		$st = floor ( $p / $sc ) * $sc;
		$en = $st + $sc;
		$g = $st;
		if ($g < "2")
			print ('') ;
		else if ($g > "0") {
			if ($g - 1 == 1) {
				$page = '?';
			} else {
				$page = '?p=' . ($g - 1) . '';
			}
			print ('<a href="' . $page . '">[&laquo;]</a> ') ;
		} else
			print ("") ;
		for($g; ($g < $en); $g ++) {
			if ($g == "1" and $g != $p) {
				print ('<a href="?">1</a> ') ;
			} elseif ($g == "1" and $g == $p) {
				print ('[<b>1</b>] ') ;
			} elseif ($g == $p) {
				print (' [<b>' . $g . '</b>] ') ;
			} elseif ($g <= $pg) {
				if ($g > "0") {
					if ($p != "1") {
						$xx = "$g";
					} else {
						$xx = $g;
					}
					print ('<a href="?p=' . $xx . '">' . $g . '</a> ') ;
				}
			} else {
				print (' ') ;
			}
		}
		if ($g <= $pg) {
			if (empty ( $_GET ['p'] )) {
				$xx = $g;
			} else {
				$xx = '' . $g;
			}
			print ('<a href="?p=' . $xx . '">[&raquo;]</a>') ;
		} else
			print (' ') ;
	}
	echo '</div>';
}
echo '<div class="main_menu">&laquo;<a href="index.php">Danh Sách Thể Loại</a></div>';
require_once ("../in/duoi.php");
?>
